﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ScriptEditor.Commands
{
    class Command_Choice : Command  //原版上限四个选项，新版上限八个选项
    {
        public ChoiceExp[] choice
        {
            get
            {
                string[] choices = Value1.Split(new char[] { '/' });
                ChoiceExp[] result = new ChoiceExp[choices.Length];
                for (int i = 0; i < choices.Length; i++)
                {
                    result[i] = ChoiceExp.toChoiceExp(choices[i]);
                }
                return result;
            }
            set
            {
                if (value.Length == 0)
                {
                    Value1 = "";
                    return;
                }
                Value1 = value[0].ToString();
                for (int i = 1; i < value.Length && i < 4; i++)
                {
                    Value1 += "/" + value[i].ToString();
                }
            }
        }
        public ChoiceExp[] choiceJp
        {
            get
            {
                string[] choices = Value2.Split(new char[] { '/' });
                ChoiceExp[] result = new ChoiceExp[choices.Length];
                for (int i = 0; i < choices.Length; i++)
                {
                    result[i] = ChoiceExp.toChoiceExp(choices[i]);
                }
                return result;
            }
            set
            {
                if (value.Length == 0)
                {
                    Value2 = "";
                    return;
                }
                Value2 = value[0].ToString();
                for (int i = 1; i < value.Length && i < 4; i++)
                {
                    Value2 += "/" + value[i].ToString();
                }
            }
        }
        public ChoiceExp[] choiceTc
        {
            get
            {
                string[] choices = Value3.Split(new char[] { '/' });
                ChoiceExp[] result = new ChoiceExp[choices.Length];
                for (int i = 0; i < choices.Length; i++)
                {
                    result[i] = ChoiceExp.toChoiceExp(choices[i]);
                }
                return result;
            }
            set
            {
                if (value.Length == 0)
                {
                    Value3 = "";
                    return;
                }
                Value3 = value[0].ToString();
                for (int i = 1; i < value.Length && i < 4; i++)
                {
                    Value3 += "/" + value[i].ToString();
                }
            }
        }
        public Command_Choice()
        {
            CommandType = COMMANDTYPE.Choice;
            choice = new ChoiceExp[] { new ChoiceExp { exp = "", text = "请输入选项内容", jumpId = "请输入跳转的ID" } };
            choiceJp = new ChoiceExp[] { new ChoiceExp { exp = "", text = "请输入选项内容", jumpId = "请输入跳转的ID" } };
            choiceTc = new ChoiceExp[] { new ChoiceExp { exp = "", text = "请输入选项内容", jumpId = "请输入跳转的ID" } };
            Wait = true;
        }
        public Command_Choice(ChoiceExp[] Choice, ChoiceExp[] ChoiceJp, ChoiceExp[] ChoiceTc)
        {
            CommandType = COMMANDTYPE.Choice;
            choice = Choice;
            choiceJp = ChoiceJp;
            choiceTc = ChoiceTc;
            Wait = true;
        }
        public override string ToString()
        {
            string s = "";
            foreach(ChoiceExp exp in choice)
            {
                s += "\n" + exp.text;
            }
            return CommandType.ToString() + ":\n" + "弹出选项:" + s;
        }
    }
}
